home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NetNews Offline 2
/
NetNews Offline Volume 2.iso
/
news
/
comp
/
std
/
c
/
201
< prev
next >
Wrap
Internet Message Format
|
1996-08-06
|
4KB
Path: solon.com!not-for-mail
From: seebs@solutions.solon.com (Peter Seebach)
Newsgroups: comp.lang.c++,comp.lang.c,comp.std.c
Subject: Re: Hungarian notation
Date: 27 Jan 1996 03:18:15 -0600
Organization: Usenet Fact Police (Undercover)
Message-ID: <4ecqkn$p1t@solutions.solon.com>
References: <30C40F77.53B5@swsbbs.com> <JSA.96Jan26175507@organon.com> <31098190.8106176@nntp.ix.netcom.com> <4eco1g$aih@fountain.mindlink.net>
NNTP-Posting-Host: solutions.solon.com
In article <4eco1g$aih@fountain.mindlink.net>,
Gene Wirchenko <genew@mindlink.bc.ca> wrote:
>>I claim that ISO 6.2.1.2 requires that an implementation actually do
>>such a conversion. The implementor may choose the mapping. Beside
>>the usual throwing away of high order bits, possibilities include
>>always using the value 0, or the largest possible value for the new
>>type, or, even, a random value.
> Implementation defined means implementation defined, not what you
>want it to mean. I agree that your interpretation sets out reasonable
>actions that might be performed. Please quote chapter and verse on
>where the Standard states that implementation defined actions must be
>"reasonable" (whatever the hell that is <G>).
Ahh, but there is the key.
My understanding (and I believe this is Mike's point) is that there is
a different between implementation defined *BEHAVIOR* and an implementation
defined *RESULT*.
My understanding is that integer conversions are an implementation
defined *RESULT*. No other *behavior* is allowed - the semantics do
not imply or show any.
This is as opposed to system(), which has implementation defined *behavior*
whenever system(NULL) returns non-zero. In particular, an implementation
could provide a command interpreter that interpreted any string as the string
to write at the beginning of every block on a disk. Such an implementation
would likely do poorly in the marketplace (unless Microsoft marketed it as
a new redundant filesystem), but would be legal.
However, given something where the *result* is implementation defined, I
would expect that no unexpected *behavior* was allowed.
This is similar to the special case where a failure to return a value from
main() results in an undefined *termination status* but is otherwise required
to behave sanely; streams must be flushed, et al. (Another ghastly thing
in Schildt's C:TCR. He says that fflush will clear the input buffer on
input streams. *sigh*.)
> Is your claim supported in the Standard? If it isn't, you're
>wasting your time. What if the conversion results in overflow?
The point of explicitly stating that the *result* is imp-defined is to
*define the behavior*.
Note that Appendix G states (wrongly) that a conversion that could overflow
results in undefined behavior. This is only true of floating point ->
integral conversions. (It is also true of operations other than
conversions.)
> Why are no side effects permitted? Chapter and verse, please.
Because none are specified. The semantics of the >> operator on signed
ints are implementation specified (or is that defined?) but no one would
tolerate it formatting disks, because it doesn't say it can, and the
wording makes it clear that no extra behavior is expected.
> What if the conversion results in overflow?
This is actually a legitimate question; if conversion is taken to be
an operation, then the previously pointed out limit on all arithmetic
ops comes into play, and we have full-fleged *undefined behavior* -
easily enough to format a disk with.
> If it is impossible to convert due to sizing, then the "must" is
>rather silly, isn't it?
Not really; it must do *some* conversion, and the conversion must be the
obvious one where that applies, and implementation-defined elsewhere.
>Right Hand of God. So what about your claims! If they can't be
>supported by the Standard, forget it. Schildt CLAIMS that void main()
>is ok.
Sadly, I am beginning to doubt that there is a true statement about C he
*doesn't* deny somewhere in that book.
-s
--
Peter Seebach - seebs@solon.com - Copyright 1995 Peter Seebach.
C/Unix wizard -- C/Unix questions? Send mail for help. No, really!
Using trn? Weird new newsgroup problem? I know the fix! Email me!
The *other* C FAQ - ftp taniemarie.solon.com /pub/c/afq - Not A Flying Toy